#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
    connect(ui->rBtnBlack, SIGNAL(clicked()), this, SLOT(setTextColor()));
    connect(ui->rBtnBlue, SIGNAL(clicked()), this, SLOT(setTextColor()));
    connect(ui->rBtnRed, SIGNAL(clicked()), this, SLOT(setTextColor()));
}

Dialog::~Dialog()
{
    delete ui;
}


void Dialog::on_checkBoxUnder_clicked(bool checked)
{
    QFont font = ui->textEdit->font();
    font.setUnderline(checked);
    ui->textEdit->setFont(font);
}

void Dialog::on_checkBoxItalic_clicked(bool checked)
{
    QFont font = ui->textEdit->font();
    font.setItalic(checked);
    ui->textEdit->setFont(font);
}

void Dialog::on_checkBoxBold_clicked(bool checked)
{
    QFont font = ui->textEdit->font();
    font.setBold(checked);
    ui->textEdit->setFont(font);
}

void Dialog::setTextColor()
{
    QPalette palette = ui->textEdit->palette();
    if (ui->rBtnBlack->isChecked())
        palette.setColor(QPalette::Text, Qt::black);
    else if (ui->rBtnBlue->isChecked())
        palette.setColor(QPalette::Text, Qt::blue);
    else if (ui->rBtnRed->isChecked())
        palette.setColor(QPalette::Text, Qt::red);
    else
        palette.setColor(QPalette::Text, Qt::black);
    ui->textEdit->setPalette(palette);
}
